package Review;

import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

class Point{
    int x;
    int y;
    int step;
}

public class Bfs {
       /*
5 4
1 1 2 1
1 1 1 1
1 1 2 1
1 2 1 1
1 1 1 2
1 1 4 3
     */

    static int m;
    static int n;
    static int p;
    static int q;
    static int min = 999;
    //a中1表示空地,2表示障碍物
    static int[][] a = new int[100][100];
    //0表示未访问,1表示访问
    static int[][] v = new int[100][100];
    //定义方向 , 顺时针 ,右下左上
    static int[] dx = {0,1,0,-1};
    static int[] dy = {1,0,-1,0};

    public static void main(String[] args) {
        Queue<Point> queue = new ArrayDeque<>();
        Scanner sc = new Scanner(System.in);
        m = sc.nextInt();
        n = sc.nextInt();
        for(int i = 1;i<=m;i++){
            for (int j = 1;j<=n;j++){
                a[i][j] = sc.nextInt();
            }
        }
        int startx = sc.nextInt();
        int starty = sc.nextInt();
        p = sc.nextInt();
        q = sc.nextInt();
        v[startx][starty] = 1;
//        dfs(startx,starty,0);
        System.out.println(min);
    }


}
